package com.risk.modules.rm.dao;

import com.sx.sx.business.entities.Scope;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ScopeDao {
    @Insert(value="INSERT INTO `scope`(`id`, `name`, `id_card`, `mobile`, `bank_card`, `rule_list_id`, `user_id`, `scope`, " +
            "`rule_list`, `create_by`, `create_time`, `update_by`, `update_time`) " +
            "VALUES (#{scope.id}, #{scope.name}, #{scope.idCard}, #{scope.mobile}, #{scope.bankCard}, #{scope.ruleListId}, #{scope.userId}, " +
            "#{scope.scope}, #{scope.ruleList}, #{scope.createBy}, #{scope.createTime}, #{scope.updateBy}, #{scope.updateTime})")
    int add(@Param("scope") Scope scope);

    @Select(value = "SELECT * FROM `scope` WHERE 1 = 1 ${whereClause}  ORDER BY create_time DESC LIMIT #{0},#{1} ")
    List<Scope> pageByCondition(int start, int size, @Param("whereClause") String whereClause);

    @Select(value = "SELECT count(1) FROM `scope` WHERE 1=1 ${whereClause}")
    int countByCondition(@Param("whereClause") String whereClause);

    @Select(value = "SELECT * FROM `scope` where id = #{id}")
    Scope get(String id);
}
